<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>登陆日志</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="{__STATIC__}/layuiAdmin/layui/css/layui.css" rel="stylesheet">
	<link href="{__STATIC__}/layuiAdmin/adminui/dist/css/admin.css" rel="stylesheet">
	<link href="{__STATIC__}/layuiAdmin/style/style.css" rel="stylesheet">
</head>
<body>
	<div class="layui-fluid">
		<div class="layui-card">
			<div class="layui-card-body">
				<div style="padding-bottom: 10px;">
					<div class="layui-table-title">登录日志</div>
					<div class="layui-form search_ctr">
						<div class="layui-form-item">
							<div class="layui-inline">
								<div class="layui-input-inline">
									<input type="text" name="keys" placeholder="输入用户名/手机/昵称查询" autocomplete="off" class="layui-input">
								</div>
								<button class="layui-btn layui-btn-normal" lay-submit lay-filter="LAY-search">查询</button>
							</div>
						</div>
					</div>
				</div>

				<table id="LAY-table" lay-filter="LAY-table"></table>
			    <script type="text/html" id="type">
					{{#  if(d.type == 'admin'){ }}
					<span class="layui-badge-dot layui-bg-blue"></span>管理员
					{{#  } else { }}
					<span class="layui-badge-dot layui-bg-green"></span>会员
					{{#  } }}
				</script>
			</div>
		</div>
	</div>
</body>
</html>
<script src="{__STATIC__}/layuiAdmin/layui/layui.js"></script>
<script>
	layui.config({
		base: '{__STATIC__}/layuiAdmin/' // 静态资源所在路径
	}).use(['index', 'table', 'form'], function(){
		let $ = layui.$;
		let table = layui.table;
		let form = layui.form;

		//初始化列表
		table.render({
			elem: '#LAY-table'
			,url: "{:url('getList')}"
			,cols: [[
				{field: 'id', width: 80, title: 'ID', sort: true}
				,{field: 'uid', width: 180, title: '账户'}
				,{field: 'ip', width: 180, title: 'IP地址'}
				,{field: 'info', minWidth: 200, title: '描述'}
				,{field: 'type', width:120, title: '类型', templet: '#type', align:'center', sort: true}
				,{field: 'add_date', width: 180, title: '时间'}
			]]
			,page: true
			,limit: 20
			,height: 'full-100'
			,text: {none: '暂无相关数据'}
		});

		//监听搜索
		form.on('submit(LAY-search)', function(data){
			let field = data.field;
			//执行重载
			table.reload('LAY-table', {
				url: "{:url('getList')}"
				,where: field
				,page: {
					curr: 1 //重新从第 1 页开始
				}
			});
		});

	});
</script>